home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Format 1994 October
/
Macformat17.cdr
/
Shareware City
/
Applications
/
Alpha.5.81 folder
/
Help
/
Intro
< prev
next >
Wrap
Text File
|
1994-06-16
|
64KB
|
1,845 lines
==============================================================================
== Copyright © 1990-1994 Pete Keleher. All Rights Reserved
==============================================================================
The Author(s) of this product are in no way liable for any direct or
indirect damage caused by the product.
You may freely copy and distribute ALPHA, but please bear in mind that
ALPHA is Shareware. If you decide to keep it, please register your copy by
sending $25 to the author. Site licences are $200. Source licenses are also
available, inquire with the author. If you include an internet (or
Compuserve) address with your registration, I will notify you when new
versions become available.
E-mail address: pete@cs.rice.edu
Snail-mail address: Pete Keleher
1658 Bonnie Brae #2
Houston, TX 77006
I am collecting user-written Tcl procs and XTCLs in public/Alpha/contrib on
cs.rice.edu. If you have written anything that you think may be of general
interest, please send it to me and I will make it available.
Alpha contains source from main places, but in particular I'm grateful to
Ray Johnson and Tim Endres for their working on porting TCL to the mac.
Thanks to Masatsugu Nagata, Karl J. Smith, Tim Endres, Eric Sink,
David C. Black, Richard T. Austin, Tom Scavo, and Jerry Fowler.
What to do: USE THE "Sections" MENU IN THIS FILE!. This file contains
"marks" that let you jump to different sections of this file. Mouse-down
on the box that says "Sections" and move to the section you need.
Alpha is a very powerful, multi-purpose editor that allows any program-
or user-defined function to be bound to any keystroke, or placed into
user-defined menus. Only the "File", "Edit", and "Search" menus are
predefined and immutable. The rest are defined in the startup file
("AlphaBits.tcl") or files sourced from inside it.
Alpha uses Dr. Ousterhout's Tool Command Language (Tcl) as an extension
language. See the "Help" menu for a complete definition of the language.
Alpha uses a port of Tcl done by Tim Endres for his "Tickle" application,
and supports many of the same extensions. Many of the functions bound to
keystrokes, as well as many of the functions in the user-defined menus, are
written in Tcl.
Callable functions in Alpha come in three different flavors. First, there
are the basic Alpha editor functions; these are discussed in the section
entitled "Simple Cmds" below. These functions take no arguments and do
not return values.
Second, there are additional Tcl extensions discussed in the "Alpha Tcl
Extensions" help file (look in the "Help" menu). Most of these functions
either take arguments or return values.
Finally, there are the Tcl functions defined with "proc". Most of Alpha's
predefined functions are in "procs.tcl", some are in "shell.tcl".
The only way to get to know the editor and the language is to try different
things out. Play around. Choose "Misc:List Bindings" to get a listing of
all the current keystoke bindings. Look in "procs.tcl" for definitions of
the routines. Look in "AlphaBits.tcl" for definitions of the last six
menus. And finally, please feel free to send suggestions/"feature"
reports/questions to me at pete@cs.rice.edu. I am not able to answer US
postal mail, but if you send it to me I will at least read it. Have fun!
==============================================================================
== Colorizing
==============================================================================
Version 5.80 and up support automatic "colorizing" of text. This is
controlled by the function 'regModeKeywords', which registers keywords to
colorize in a specific mode. By default, color schemes are supplied for
C, C++, Tcl, and TeX. Colorizing can be turned off via the 'coloring'
flag.
==============================================================================
== Reading and Storing Files
==============================================================================
The primary method of either reading or storing files with Alpha, or any
other Mac editor, is through the GetFile and PutFile dialogs. However,
Alpha's dialogs are not exactly like those of other applications.
The GetFile dialog has two additional items: a "Readonly" checkbox and an
"All Files" checkbox. The first allows you to open a file as read only.
Files in the readonly state can not be modified, only read. A writable file
is indicated by a pen icon to the left of the horizontal scrollbar. A
readonly file is indicated by a pen with a line through it. If you change
your mind about the file, it's readonly status can be changed by clicking
on the pen icon.
The second checkbox, "All Files", allows Alpha to open any file rather
than just those of type 'TEXT'. The type of a file can be determined by
using the 'll' alias in the Tcl shell.
The PutFile dialog is used to prompt the user for a new name under which to
save the contents of a window. This dialog has been enhanced by two popup
menus: "State" and "Format". "State" allows you to specify how much
information should be saved in the resource fork of files that you use. If
the state is set to "MPW", window position, current selection, tab sizes,
and font information are saved into the resource fork of your application
every time you open and close it, *even if you don't modify the file*.
Alpha still manages to coexist with build or make files because saving this
information does not change the modification date of the file. If the state
is set to "Think", neither the window position nor the current selection
are saved. If state is set to "None", no information is saved. The default
value for saved state can by changed by setting the Alpha variable
'savedState' to "mpw", "think", or "none". Note that if a given file
already has mpw information in it when the file is open, Alpha will always
update that information when the file is closed. Note also that "marks"
are always saved in the resource fork whenever a file is saved,
regardless of the setting of the 'savedState' variable.
The "Format" menus allows the way Alpha terminates lines to be changed.
The Mac uses a carriage return to mark the end of a line, Unix uses a
linefeed, and IBM uses both (of course). Alpha can read and write any of
these formats, and can convert between them just by opening a file,
choosing "Save As", and changing the selection in this menu. Note that if
you are going to be sharing files with a Unix or IBM machine, you
probably don't want anything in your resource fork, so you'd probably
want to set 'savedState' to 'none' in your AlphaBits.tcl file.
==============================================================================
== The Window
==============================================================================
Alpha's windows have several non-standard features.
First, on the title bar at the left, there are either one or two boxes. If
there is only one box, the box implements a popup menu of all marks set in
the file. If there are two boxes, the left box implements a popup menu of
all functions in the current file (as defined by the 'funcExpr' regular
expression) and the right box implements the mark menu. These boxes can
be turned off via the flag 'showMenuHeads' in the "Utils:Flags" submenu.
On the right of the titlebar, there is a running display of the current
row and column. These boxes can be turned off via the 'showRowCol' flag.
All title-bar boxes are turned off when Alpha is using full names for
window titles.
At the bottom of the window, the first box is a status display area.
Also, "Utils:Execute…" prompts for a Tcl expression in this space. To the
right of the status area is an icon displaying the readonly status of the
file. If the icon is just a pen, the file is writable. If the icon is a
pen w/ a bar through it, the file is not writable. The readonly status of
the window can be toggled by clicking on the icon.
To the right of the readonly icon area is the mode display area. Alpha
allows you to have any number of different modes, w/ different bindings
and behavior in each. The mode display not only shows the current mode,
but also implements a popup menu allowing you to change the current mode
for the window.
==============================================================================
== Marks
==============================================================================
Alpha allows the user to use "marks" to remember positions in files. Marks
"float". That is, if a mark is initially at position 312 and then five
characters are inserted at location 297, the mark's new value will be 317.
Alpha uses three different types of marks.
The first is generically referred to as "the mark". The mark is set to the
current insertion point by the command 'setMark' (control-space by
default). The position in the file indicated by the blinking cursor is
referred to as the current insertion point. Many commands (such as "cut"
and "copy") can operate either on the currently selected (hilighted) text,
or the text between the current insertion point and "the mark". For
example, if you move the cursor to the beginning of the work "allybaba",
hit command-space (the status bar should say "Mark set"), move to the end
of the word and hit option-w (the status bar should say "Region copied"),
the effect is the same as if you had used the mouse to select the text and
then selected the "Copy" command from the "Edit" menu.
The second type of mark are the permanent marks. Permanent marks are set,
removed, and moved-to through the three corresponding menu items in the
"Search" menu. Permanent marks differ from the generic mark in that they
have names, there can be any number of them, and they are saved in the
resource fork if the file is subsequently saved.
The third type of mark is the temporary mark. Like permanent marks,
temporary marks can be named and there can be any number of them. Unlike
permanent marks, temporary marks do not "dirty" the file, and they aren't
saved. So far, temporary marks are used exclusively to implement higher
order functions in TCL procedures. In the 5.0 release, temporary marks are
used to implement a "mark stack" and a for loop template.
At the time a file is saved, the marks for that file are stored into the
file's resource fork in an order determined by the variable
'markSorting'. The choices are either 0 (no sorting), 1 (sort by file
position), or 2 (sort alphabetically).
==============================================================================
== The Mark Stack
==============================================================================
The mark stack is a last-in-first-out (LIFO) stack of temporary marks
managed by the TCL procedures 'pushMark' and 'popMark'. 'pushMark' creates
a new temporary mark of the current insertion point and adds it on to the
top of the stack. 'popMark' removes the top mark from the stack and goes
toit. A typical use of the mark stack is a 'pushMark' at the current
position, go look somewhere else in the file, and then 'popMark' to get
back to where you were. However, the stack is recursive, so there can be
any number of 'pushMarks' before the marks start to be popped back off the
stack.
==============================================================================
== Templates
==============================================================================
Temporary marks can also be used to with language construct templates. The
file "template.tcl" contains an example implementing a template for C's
'for' command. Depressing control-i will insert a template for the "for"
command into the current window. Five temporary marks are defined in the
for structure, three inside the parenthesis, one where the "for" body text
will be inserted, and one after outside the for body entirely. Depressing
control-shift-i moves the cursor to the next of the five temporary marks
allowing quick entry of the entire command.
==============================================================================
== The Tool Command Language (TCL)
==============================================================================
See the Tcl manual page under the 'Help' menu for a complete description of
Tcl, the Tcl shell, and it's commands. Each of the Tcl commands and several
sections have a mark defined, so you can use the "Mark" titlebar menu to
navigate through the manual page. If you define the file
":Tcl:UserCode:userStartup.tcl", Alpha will load it at startup.
==============================================================================
== Key Bindings
==============================================================================
Any TCL command can be bound to any single keystroke. One way to bind a
function is with a statement such as:
bind 'c' <modifier string> funcName [<mode>]
where c is a character, <modifier string> is an optional string containing
one or more of:
c - command modifier
o - option modifier
s - shift modifier
z - control modifier
e - escape modifier
Additionally, the modifier string can contain a capital letter specifying
that the binding is only activated if preceded by control and the lowercase
version of that letter. This feature allows multiple-key combinations ala
Emacs. The following line binds cmd-shift-f to the function 'forwardChar':
bind 'f' <cs> forwardChar
The next line would bind the same function to C-x C-f:
bind 'f' <cX> forwardChar
'mode' is an optional parameter that specifies, when present, that the
binding is only active in a given mode, where the current mode is the
parameter to the last call of 'displayMode' (look in "procs.tcl"). Note
that given a general binding (no mode specification) and a binding specific
to the current mode, the last binding to have been created is the one found
first.
Additionally, most keyboards have keypads and/or Function Keys. These
keys can be bound using case-insensitive numeric labels using the same
bind command as above, with the label replacing the character. For
example, to bind F1 to function 'funcName', the following would work:
bind F1 funcName
As above, the binding can include a modifier string. The following labels
are defined for US keyboards:
Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 Help Home Pgup Del
End Pgdn Left Right Up Down Clear Kpad0 Kpad1 Kpad2 Kpad3 Kpad4 Kpad5
Kpad6 Kpad7 Kpad8 Kpad9 Kpad= Kpad/ Kpad* Kpad- Kpad+ Enter Kpad.
The function 'listBindings' will list all of the bindings currently in
effect in a format suitable for re-loading.
The above labels may not be sufficient for all keyboards (attention
international users). If a hex number is used instead of a character inside
the single quotes, the binding is done to key codes instead of ascii
values. The following is a key code version of the same binding:
bind 0x03 <cs> forwardChar
The key code for any given key can be obtained by using the 'keyCode'
function.
Also, there is an alternate form that allows the specification of an
ascii code directly:
ascii 0x20 <z> setMark
Binds control-space to 'setMark'.
Note that menu item command equivalents take precedence over bindings,
and that the 'bind' command does not affect the command equivalents
displayed in the menus. Command equivalents can only be changed by using
an external tool like 'ResEdit'. Also note that key code bindings take
precedence over ascii bindings.
Finally, there is an 'unbind' key, with the same arguments as bind except
for the function argument. The function is the following is the syntax:
unbind 'c' <modifier string> [<mode>]
==============================================================================
== Menus
==============================================================================
Alpha's menus are completely reconfigurable. Some of the menu items are
internal alpha commands, while others are Tcl procs defined in one of the
files of the "Tcl" subdirectory. Most of these procs are defined in
"procs.tcl". The following is an explanation of the default menus. The
explanations of items that are defined as Tcl procs are implemented by the
Tcl proc specified by "(proc <name>)", and can be found in one of the .tcl
files. All others are internal functions.
File
New New file.
Open… Open file.
Close Close file.
File Sets
Choose Set current fileset.
Create Fileset Create a fileset on the fly.
Create Think Fileset Create a fileset containing the source files
of a THINK 7.0 project.
Dump Fileset Dump a fileset definition into the current window.
Edit File Edit a file from one of the filesets.
Find Tag Find a function definition.
Create Tag File Create a "tag" file specifying where functions
are defined.
Save Save file.
SaveAs… Prompt for name to same file under.
Revert Revert to last saved version, throw away undo history.
Shell Start up command-line shell that interprets Tcl commands. The
shell has a few csh-type features, such as 'ls', 'rm', etc.
commands, as well as file completion with the TAB key.
Page Setup… Set print options.
Print… Print file.
Quit Quit Alpha.
Edit
Undo Undo.
Redo Redo.
Load Window
Load Selection Execute either the window or the selection as Tcl source.
Cut Cut selection to scrap.
Copy Copy selection to scrap.
Paste Paste from scrap.
Paste Pop Immediately after a paste, use a previous paste instead.
Yank Paste last deleted text. Concatenates together consecutive,
adjoining deletions.
Select All Select entire file.
Clear Delete selection.
Shift Left Shift selection left one tab.
Shift Right Shift selection right one tab.
Balance Select text out to the next set of matching braces.
Search
Find.. Present a search dialog.
Repeat Search Forward Search forward again w/ same settings.
Repeat Search Backward Search backward again w/ same settings.
Find in Next File Restart multiple-file search in next file after
stopping at a match.
Enter Selection Make the current selection the text to be searched for.
Replace Replace the selection.
Replace and Find Again. Replace the selection and search again forward.
Replace All Replace all of occurances of the search string in the rest
of the file.
Goto Line… Go to specific line.
Named Marks
Set…
Goto…
Remove…
Unnamed Marks
Set…
Exchange Point and Mark
Hilite Select text between current insertion and the generic "mark".
Or, if there is already a selection, unselect the text, place
the insertion at the beginning of the unselection, and place the
"mark" at the end of the unselection. The function
'exchangePointAndMark' (by default mapped to the "5" on the keypad
and control-x,control-x) exchanges the character positions of the
insertion and the "mark".
Mark Stack
Push Push current pos onto a "stack".
Pop Pop last pos from stack and go to it.
Utils
Flags A submenu of Tcl flags to be turned on and off. Look under
"Variables" for explanations of individual flags (proc editFlag).
Vars Same as Flags, except these variables may be arbitrary integers
or strings (proc editVar).
File Utils
Insert Path Name… Prompt for a file and insert complete pathname in window.
Insert File… Insert the text of another file.
File Remove… Remove a file.
File Info… Display/edit info about a file.
Word Count Count lines, words, chars in window (proc wordCount).
Evaluate… Evaluate complex command.
Kbd Macros
Start Keyboard Macro Start creating anonymous macro.
End Keyboard Macro Finish.
Execute Keyboard Macro Execute.
Dump Macro Dump to current file.
Spellcheck Window
Select Paragraph
Named Clipboards
Copy…
Cut…
Paste…
Mode
Set Mode Menus Decide which menus will pop up during this mode.
Describe Binding… Wait for a keystroke, then display that keystroke's binding.
List Bindings Create a new file containing all current key bindings.
Ascii Etc
Key Code… Wait for key press and insert keycode and modifier string
suitable for key binding.
Key Ascii… Same as above, but use ascii form.
Get Ascii… Display ascii code for char to right of insertion.
Insert Ascii… Prompt for ascii code and insert character.
Set Font Tabs… Change font and/or tabs for current file.
Switch To Bring other apps to front.
ToolServer Shell Start a window that sends 'DOSC' events to Apple's
toolserver.
Load Electric Alias Load David Black's 'electricAlias' package. See the
"Help" menu for more details (proc loadElectricAlias).
Convert
Fill Region "Fill" selection subject to 'leftFillColumn' and
'fillColumn', (proc fillRegion).
Fill Paragraph "Fill" paragraph that contains the insertion (proc
fillParagraph).
Wrap Region Break lines longer than 'fillColumn' in selection
(proc wrapRegion).
Wrap Paragraph Break lines longer than 'fillColumn' in paragraph
containing insertion pt (proc wrapParagraph).
Sort Lines Sort selected lines (proc sortLines).
Matching Lines Grab all lines from current position on that match a
regular expression and dump in new buffer (proc matchingLines).
Zap Invisibles Delete all chars in file w/ ASCII code < 32, except for
LF, TAB and CR.
Tabs To Spaces Convert tabs to space runs.
Spaces To Tabs Convert space runs to tabs.
Strings
Insert Prefix Prepend string 'prefixString' to every line in selection
(proc insertPrefix).
Insert Suffix Append string 'suffixString' to every line in selection
(proc insertSuffix).
Remove Prefix Remove prefix string from lines in selection
(proc removePrefix).
Remove Suffix Remove suffix string from lines in selection
(proc removeSuffix).
Set Prefix… Change prefix string (proc setPrefix).
Set Suffix… Change suffix string (proc setSuffix).
Comment
Transpose Chars Transpose two chars around cursor.
Transpose Words Transpose two words around cursor.
Comment Box Create a comment box around selected text.
UnComment Box Remove such a comment box.
Filters
Replace In Region
Filter Lines
Filter Paragraphs
Sort Paragraphs
Fill Region By Par
Line To Paragraph Convert long line to paragraph, useful for importing
text from word processors (proc lineToParagraph).
Paragraph To Line Convert paragraph to single long line, useful for
exporting text to word processors (proc paragraphToLine).
Downcase Region Downcase all chars in region.
Upcase Region Upcase all chars in region.
Help
Editor help files (proc helpMenu).
Wins
Arrange Rearrange open windows.
Zoom Zoom windows in and out.
Iconify Replace window w/ small icon (proc iconify).
Toggle Scrollbar Toggle the horizontal scrollbar on the frontmost
window. The scrollbar can be enabled/disabled on subsequent
variables by changing the value of the 'horScrollBar' flag.
Next Window Select next window (proc nextWindow).
Swap With Next Swap topmost two windows (proc swapWithNext).
Choose A Window Choose window to select from list (proc chooseAWindow).
Prev Window Select previous window (proc prevWindow).
Close All Close all windows (proc closeAll).
Save All Save all dirty windows (proc saveAll).
==============================================================================
== User-Defined Menus
==============================================================================
All of Alpha's menus are defined in the initialization files that Alpha
loads on startup. They can be altered or discarded at well. Alpha's menu
commands allow the the user to build custom menus which contain names of
functions, macros, or arbitary TCL commands that just HAVE to be in the
menus, as opposed to being merely callable through the bindings. The
syntax is dead simple. Menus can be nested, allowing heirachical menus to
be defined. See the 'AlphaBits.tcl' file for examples (only the first
three Alpha menus are hard-coded into the Application, the others are set
up through the AlphaBits file). The following meta characters can be
embedded in the strings:
Meta-character Usage
-------------- -----
; or Return Separates multiple items.
^ Followed by an icon number, adds
that icon to the item.
! Followed by a character, marks the
item with that character.
< Followed by B, I, U, O, or S, sets
the character style of the item.
/ Followed by a character, sets up
a keyboard equivalent.
( Disables the item.
The menu creation syntax is :
menu <-n name> <-i num> [-p procName] [-m] "Tcl list of items"
Where the arguments have the followings meanings:
'-i <num>' Resource id of icon suite to use for menu title.
'-n <name>' Name of menu.
'-m' No menu form. If not supplied, each menu item is split into
words at each capitalized letter.
'-p <pname>' Rather that having alpha call a Tcl proc named by the menu
item's text, this option tells Alpha to call the tcl proc named by
'pname' with two arguments: the menu name, and the text of the menu
item chosen.
Once the menus are created, they can be inserted and deleted from the
menu bar by the syntax:
insertMenu "name"
deleteMenu "name"
as well as through macros.
As alluded to above, Alpha attempts to make procedure names readable in the
menus by separating words at any capitalized letter. For example,
'findFile' becomes "Find File". This function is turned off by the '-m'
option.
Menu items can be enabled and disabled through the TCL command
'enableMenuItem'. Menu items checkmarks can be turned on and off via
'markMenuItem'. Menu items can be appended via 'addMenuItem' and deleted
via 'deleteMenuItem'. See the "Alpha Tcl Extensions" help file for syntax.
If an ellipsis ('…') is the last character in a menu item, it is stripped
off before searching for the function corresponding to the chosen item.
#================================================================================
# Just for the heck of it, the following is a script that I put in my
# userStartup.tcl file. It creates a menu for all the .tex files in my
# thesis directory, minus the dirname and .tex extension.
#
set THESIS "Internal:Textures:thesis"
proc thesisMenuProc {menu item} {
global THESIS
edit -r -m $THESIS:$item.tex
}
set files ""
foreach f [glob $THESIS:*.tex] {
lappend files [file rootname [file tail $f]]
}
menu -n Thesis -m -p thesisMenuProc $files
unset files
#================================================================================
==============================================================================
== Event Hooks
==============================================================================
Alpha calls the TCL procs "openHook", "saveHook", "saveasHook", "closeHook",
"activateHook", "deactivateHook", "suspendHook", and "resumeHook" when the
corresponding events occur. With the exception of "saveasHook", the proc
are all called with the complete pathname as the sole argument.
"saveasHook" is called with the old pathname as the first argument and the
new pathname as the second argument. Default implementations for these
commands are in the file 'proc.tcl'. These commands can be modified to
perform arbitrary commands, including saving of files, backups,
implementations of per-window variables, etc.
==============================================================================
== Searching
==============================================================================
ALPHA has a full repertoire of searching commands. The 'find' command
brings up a dialog allowing the search and replacement text to be
specified. The dialog also allows 'Forward', 'Ignore Case', 'Reg Expr',
and 'Word Match' options to be set. These options can be toggled via the
keyboard by clover-<first letter of option>. For example, clover-w toggles
the 'Word Match' option.
The 'Mult Files' option tells Alpha to search through all files in a given
file set. Filesets can be specified in 'procs.tcl' (see the section on
filesets) or on the fly, via the "Add Fileset…" item of the "Utils" menu.
Filesets can be chosen via the popup fileset menu.
In addition to the current filesets, the fileset menu has an entry called
"Directory Scan". Selecting this menu item enables the "Scan Options"
button. This button, in turn, allows the specification of a directory and
a file pattern to be searched instead of a fileset. To set the directory,
hit the "Dir:" button. The pattern is used to select files of the
selected directory. The '*' wildcard character can be used to replace any
sequence of characters. For example, the pattern '*.c' will select any
file ending with ".c". If this doesn't work, be sure that you executed
all of the following steps:
1) select "Directory Scan" in the popup menu of the find dialog
2) Hit the "Scan Options" button.
3) Select a directory via the "Dir:" button.
And finally, Alpha allows a library of useful search and replace texts to
be defined as a tcl list of lists (each sublist containing a name, search
text, and replacement text). This list, the 'patternLibrary' variable
defined at the end of 'procs.tcl', is used to create a popup menu in the
find dialog allowing these patterns to be easily entered.
Once the text and options have been set, the 'Search' menu contains several
commands for repeated searching, replacing, etc.
==============================================================================
== Regular Expressions
==============================================================================
If the variable 'regExpr' is true, the search functions interpret the
search text as regular expressions, which have the following elements:
c literal char.
^ beginning of line.
$ end of line.
. any character except carriage return.
[...] character class, can use ranges such as '0-9'.
inside classes. Matches one character of the
enclosed choices. Ex: '[ac0-2]' matches 'a',
'c', '0', '1', or '2'.
[^...] negated character class, matches anything but
the enclosed characters. ']' can be included
by putting it immediately after the '^'.
\t tab.
\r carriage return or line break.
* zero or more occurrences of the previous
pattern. Ex: 'ab*' matches 'a', 'ab', 'abb',
'abbb' etc.
+ one or more occurrences of the previous
pattern.
? zero or one occurrences of the previous
pattern. Ex: 'ab?' matches 'a' or 'ab'.
a|b matches either a or b. If enclosed in
parenthesis, the extent of the alternated
expressions is limited. Ex: (pete|bob)
matches either 'pete' or 'bob'.
(...) The interior elements are grouped together.
Regular expressions constructed from the above elements can be
concatenated to create larger expressions.
The parenthesis also define substrings of the total matched string that
can be used either later during substitution. The substring delimited by
the pair of parenthesis that includes the nth left paren is denoted \n,
where n is 1, 2, .... 9. '\0' and '&' both refer to the matched text.
EXAMPLE:
The following regular expression will match either 'aabox' or 'bbbox':
(aa|bb)box
Regular expressions can be very difficult to master, but they the
following section shows how useful they can be.
The text used in searches and replaces can be accessed through the alpha
variables 'searchStr' and 'replaceStr'.
==============================================================================
== Incremental Searches
==============================================================================
Emacs users will be happy that both forward and backward incremental
searches are implemented. Incremental searches bypass the normal search
dialog and search for the current text after each keystroke. The result is
often much faster and less intrusive. Executing either while an incremental
search is in progress causes the search to proceed to the next instance of
the current text. Incremental search mode is exited when any other command
(executed through the menus or through bindings that include at least one of
the control key and the option key) is executed, or when the escape or
delete key is used. Typing control-w while incremental search is active
causes all the characters to the end of the next word boundary to be
added to the search.
==============================================================================
== 'C' Tags
==============================================================================
ALPHA supports the use of tags to find declarations of functions. When
searching for a tag, ALPHA looks for the tag file specified by the
"tagFile" string variable. ALPHA's tag generating routines use the regular
expression in the string variable "funcExpr" to look for function
declarations. In other words, we don't parse the text. If you declare your
functions differently, you can change " funcExpr" to suit your own style.
Alpha currently uses the following regular expression to find C function
declarations:
^[^ \t#\r/@][^\r]*\([^\r]*\)$
(NOTE: the above expressions won't pick up many C++ method definitions. To
pick them up, add a question mark '?' after the last right parenthesis.)
Although complicated, this expression makes sense if you slowly wade
through it. The string that we are looking for must take up an entire
line. It must begin with a character other than '\t', '#', '\r', '/', ' ',
or '@'. There must be a set of parenthesis.
Note that not only can you customize this to your style of 'C'
declarations, you could also use it to generate tags for other languages.
The only thing you need to bear in mind is that the tag routines use the
complete word previous to the first '(' in the selected line as the
function's name. If there is no '(' in the selected line, the last word in
the line is used. Therefore, Pascal procedures w/ or w/o parameters can be
identified.
================================================================================
== Backups
================================================================================
If the 'backup' variable is set in userStartup.tcl, or from the
Utils:Flags menu, Alpha backs up each file before saving new
modifications. By default, the backup file is in the same directory, and
its name is formed by suffixing a tilde to the name of the saved file.
Backups are actually performed in the 'saveHook' proc (see above), in the
file procs.tcl. The Tcl variables 'backDir' and 'backExtension' can be
used to modify this behavior.
==============================================================================
== "Fill" Routines
==============================================================================
The "fill" and "wrap" routines reformat text to specified line lengths.
This is useful in two case. First, word processors such as Microsoft Word
only insert carriage returns at the end of paragraphs. Secondly, while
typing and inserting text into pre-existing paragraphs, the line lengths
become unequal.
The "wrap" routine handles word processor documents quickly by merely
inserting carriage returns as necessary to ensure all lines in the
selected region are shorter than specified by the variable 'fillColumn'.
Alpha asks the user if wrapping should be done whenever the user opens
files that have lines longer than 'paraColumn' characters.
The TCL routines 'fillRegion' and 'fillParagraph' go further. Not only do
they break lines, but they also coalesce lines to eliminate short lines.
Both routines work by stripping the relevent text of white space, then
re-inserting white space and carriage returns so that no line extends past
'fillColumn' characters in length and begins with 'leftFillColumn' spaces
characters. Both routines are implemented in the file 'procs.tcl', and
therefore different definitions of paragraphs can be accomodated by
modifying the appropriate TCL procedures.
==============================================================================
== Titlebar Menus
==============================================================================
If the value of the variable 'showMenuHeads' is non-zero, every text window
contains two boxes in the title bar. By default, the first contains a box
entitled "Func". Depressing the mouse in this box bring up a popup menu
containing a "Mark File" item, followed by a separator, followed by all the
permanent marks in the file. "Mark File" causes Alpha to call the tcl
proc 'markFile'. This routine, depending on the mode, calls a
mode-specific routine to create a list of marks definining all the
procedures or sections in the file. In order to remove any extraneous
marks, remove all marks in the file (via "Search:Named Marks:Remove…" and
selecting "All").
The second box contains the current row and column. Clicking in this box
brings up a goto-line dialog.
==============================================================================
== Word Breaking
==============================================================================
Alpha allows you to redefine it's internal notion of what a word is,
through the variables 'wordBreak', and 'wordBreakPreface'. 'wordBreak' is
set to a regular expression that defines a word to you. 'wordBreakPreface'
should be a regular expression that matches exactly one of any characters
that are not in your word definition.
For instance, the default definition of 'wordBreak' is '[a-zA-Z0-9_]+'.
This matches any contiguous sequence of contiguous alphanumeric
characters, plus underscore.
The default value for wordBreakPreface is '[^a-zA-Z0-9_]', basically just
the negation of any any of the characters in your 'wordBreak' definition.
The need for both these variables in backward searches can be seen as
follows. Suppose your window's text is "hey hello", and the current
insertion is between the two 'l's. Now, searching backwards for the above
'wordBreak' definition will take the insertion to between the 'e' and the
first 'l', not really where we want to say is the start of the word. By
contrast, if we search backwards for 'wordBreak' and 'wordBreakPreface'
concatenated together, and then move forward one character after a
successful search, we end up right before the 'h' in 'hello', just where
we want to be.
==============================================================================
== Defining and Using File Sets
==============================================================================
File Sets are lists of files that Alpha uses for multiple-file searches and
tag searches, among other things. Typically, a user will set up several
different file sets in the AlphaBits.tcl file, perhaps one specifying all
the source files in a project, another specifying all the Mac include
files, and another specifying all the UNIX include files. When a command
using file sets is initiated, Alpha evaluates the command "getCurrFileSet",
which returns a list of complete pathnames to search. Some of the lists are
set up explicitly (see the 'noGlobNecessary' definition in "procs.tcl"),
while other file sets are defined at startup time through the use of file
globbing. See the TCL manual page for a definition of "glob"ing. The
definition of the variable "globNecessary" in "procs.tcl" shows how to to
this.
Functions that use file sets operate on the "current" fileset, which is
specified by the 'fileSet' variable. The current file set can also be
switched by using the "File Set" heirarchical menu.
5.02 includes a new Tcl proc 'addFileset', which allows a fileset to be
created on the fly. This
fileset remains usable until Alpha is restarted. It should be quite simple
to use Tcl to make this new fileset permanent. A Tcl proc could also be
written to create a heirarchical menus that has a submenu for each fileset,
the items of each submenu being the files for that fileset. However, I'm
not going to write everything...
=============================================================================
== Keyboard Macros
=============================================================================
Defining and Using Keyboard Macros ALPHA supports keyboard macros which
record a sequence of keystrokes to be played back later w/ the function
'executeKeyboardMacro' (this function is also in the 'Utilities' menu) or
written into a buffer by selecting 'Dump Macro' from the 'Utilities' menu.
The dump function prompts you for a macro name, which must consist only of
letters of the alphabet, digits, and '_'.
These macro declarations can then be edited, loaded, and bound to
keystrokes. Loading a macro or a binding is accomplished by hiliting the
text and selecting the "Load Selection" item of the 'Customize' window. If
no text is hilited, the entire window is loaded by the same command.
Macros can be bound to keys in exactly the same manner as functions (see
above).
=============================================================================
== Undo + Redo
=============================================================================
ALPHA supports unlimited undo and redo. This means that most changes can
be undone, and then redone, at will. Bear in mind that once you create new
modifications, all changes that you have undone but not redone are lost.
Another point to bear in mind is that saving a buffer to disk currently
flushes the undo buffer.
=============================================================================
== Think 6.0
=============================================================================
Yes! Finally Think has support for external editors. To make this work,
put an alias of Alpha (version 5.5 or later) in the "Tools" subdirectory
of the directory the project manager is in, and name the alias "Editor".
Secondly, check the "Use External Editor" button in the project manager's
option dialog. Finally, check the "Always Check File Dates" button.
Any open window events will now be vectored to Alpha, and from within
Alpha you can initiate compiles, disassembles, makes, etc. Errors are
reported back to Alpha displayed in a window titled "Browser". The only
useful things to do in the browser window are to select the error you
want (by moving up and down w/ the arrow keys), and telling Alpha to
display the error by hitting return or Enter on the correct line.
Caveats and comments:
1) This is all very shaky right now, I'm currently short of time.
2) Think's event support isn't all there. In particular, I've
seen some bombs caused entirely by the project manager, and the
"Make" apple event doesn't appear to do anything.
3) Think's debugger currently doesn't accept Apple Events telling it to
open a file and go to a specific line. This will change in the near
future. In the meantime, it is not possible to tell the debugger to
go to a specific line at all, when using an external editor. You CAN
go into think, select a file name from the project window (don't open
it) and go to the debugger from there. This gets the debugger to the
file you want, but not the correct line.
4) Look in :Tcl:SystemCode:"think.tcl" and "browser.tcl" for the code
controlling much of the interactions between THINK and Alpha. If you
improve anything, please send it back to me.
For pre-6.0, after editing w/ Alpha hit the 'Use Disk' button from the
'Build' menu item to force Think to check modification times for a build.
=============================================================================
== Rectangular Editing
=============================================================================
If the option key is pressed while the mouse is dragged, a rectangular
section of text is selected instead of the normal selection. This
rectangular selection may extend over multiple lines, but contains only
text between the column of the drag start and the column of the drag end.
The drag cannot end on a column or row less than the start. This selection
can be extended by option-shift-mouse, but not dragged further.
The rectangular selection can be deleted, copied, and pasted. This is very
useful for tables and arrays, such as in LaTeX. Usually, the operation
will be intuitive. However, if you use proportional fonts the selection
may appear ragged. If some of the line contain tabs, the result may not be
want you want. Converting tabs to spaces in the desired region before
attempting rectangular selection usually fixes the problems.
The most natural semantics of rectangular selection aren't obvious. I
chose to implement it in a similar fashion to that of Microsoft Word.
Preditor does it in another way, and has many bugs (and it's commercial,
hah!).
=============================================================================
== Using LaTeX
=============================================================================
As I am starting to write papers on my Mac using OzTeX, Alpha may migrate
increasingly into the realm of LaTeX users. For starters, LaTeX support
includes:
• automatic word-wrapping.
• fill paragraph and fill region commands.
• support for changing paragraph definitions
so that a backslash limits paragraph extent.
• rectangular editing mode, useful for working
with tables and arrays.
• title-bar section menu.
• suffix hook for .tex (see the section on suffix
hooks) that can automatically enable all this.
The only one of the above items that hasn't been explained is the title-bar
section menu, which is specified by appropriate settings of 'funcExpr',
'funcPar', and the function 'winFuncTitle'. For files ending in ".tex",
the title-bar contains a box labeled "Sect". Clicking on this box creates
a popup menu containg all section definitions in the current file.
Selecting one puts the cursor at the beginning of the section. See the
Popup Menus section and the startup files for more information.
In addition, distributions from 5.0 on include a ``latex.tcl'' file that
has many useful latex'ing macros. Finally,
"public/Alpha/contrib/smart.tcl" on cs.rice.edu contains macros that
implement smart quotes. By default, this file is loaded when latex.tcl is
loaded.
=============================================================================
== The (Dreaded) Option Key
=============================================================================
ALPHA's default setup uses the command key like any other mac application.
Problems arise in ALPHA's emulation of emacs key bindings. Emacs uses an
escape key and a control key. Alpha's default configuration is set up for
Mac II's. Emacs's escape and control keys are emulated by the Mac's
corresponding keys. For Mac+'s, however, the situation is much more
complicated. They don't have an escape key, so the the backquote key, '`',
must be used instead. This can be set up by uncommenting the appropriate
line in the "AlphaBits.tcl" file. Also, Mac+'s don't have control keys, so
the option key can be used instead. However....
Using the option key isn't quite that simple. First, the option key is
already used in two contexts. There may be other option bindings. Also, if
the variable 'optionIsEscape' is set, the option key is treated as if it
is an escape so as to allow single keystroke calls of Alpha functions. In
order to use the option key as an escape key, this variable must be set to
zero in the AlphaBits file. Also, all the relevant bindings must have
their modifier strings changed from using 'z' to 'o'.
There are other problems. Several option combinations are "dead keys"
(option-e, option-o....), they are used to create bizarre (sorry to y'all
non-Amuricans) characters through multiple keystrokes. Alpha can fix this
by overlaying the system 'KCHR' resource with a private modified resource.
This happens at startup time if the "AlphaBits.tcl" file specifies a zero
value for the variable 'noRemapOption'. Unfortunately, this is just a US
version of the resource, it won't work "fur the non-Amuricans".
=============================================================================
== System Software 7.0
=============================================================================
Alpha is 32-bit clean and high-level event aware.
Under 7.0, Alpha uses temporary memory to accommodate large files. This
allows you to open multi-megabyte files even when Alpha's partition is set
only at 512k, if the system has that much memory available. Note that
using temporary memory makes that much memory unavailable to other
applications. Contrary to all admonishments, Alpha does not unlock
temporary memory across WaitNextEvent calls and may eventually use all the
memory in your system. You can turn this feature off through 'tempMem'.
Note, however, that the clipboard is allocated by the system in Alpha's
heap, and therefore cannot take advantage of temporary memory.
=============================================================================
== Apple Events
=============================================================================
See the Help file on AppleEvents.
=============================================================================
== MPW
=============================================================================
Alpha's 'dosc' capability (see the function "dosc") can be used to send
events to MPW's ToolServer. Using about ten lines of C code and the ~40
lines of Tcl code in 'mpw.tcl', I created a pseudo mpw shell (look under
the "Misc" menu). This shell uses Alpha's 'dosc' function to package each
shell command up into an Apple Event and send it to the ToolServer, which
then evaluates the command and returns the result to be displayed in the
shell. I'm rather new to Apple Events and the ToolServer, so there are
probably a few rough edges.
If anyone has extensive docs for ToolServer I'd appreciate looking at them.
I only have the application because I am a beta tester for another product
that supports ToolServer. I was given the application for the beta testing,
but not any docs. And of course, I can *not* give away copies of
ToolServer because it is a licensed Apple product.
Finally, Tom Moertel (thor@vivaldi.psu.edu) has written and provided a set
of tools that make life easier while writing code in Alpha for the MPW
environment. The tools make extensive use of Apple Events, so you must be
using MPW 3.3a or greater. (Earlier versions cannot receive commands via
Apple Events.)
With the MPW-Alpha package you can:
o Send TCL commands to Alpha from MPW
o Use MPW 411 from Alpha for instant access to programming help
o Automagically locate source code errors from your last MPW compile
o Use the MPW CDent tool to reformat (grind) C/C++ source code
from within Alpha
This package is available via anonymous ftp from cs.rice.edu.
=============================================================================
== File Formats
=============================================================================
Alpha reads and writes files stored in three (or maybe four) different
formats. The three main formats are mac (lines end with a carriage
return), unix (lines end with linefeed), and IBM pc (lines end with both
carriage return and linefeed. Typical, isn't it?).
Alpha will transparently read and write all three of these formats. You
don't have to do anything special to use different formats, but the
'SaveAs...' dialog allows you to specify the format that a file is written
in through the 'Format' button.
The fourth file format is just a modification of the ordinary mac format.
Word processors such as Microsoft Word and MacWrite only put carriage
returns at the end of paragraphs, so that they can wrap the paragraphs on
the fly. This is what is referred to as 'paragraph format' in the rest of
the help text. Alpha does not transparently convert to and from this
format because there are valid reasons why someone might want to edit a
paragraph formatted file while not in paragraph mode.
Therefore, when Alpha detects reads a paragraph-mode file, it asks the
user whether or not to remap it. Files can be mapped back to paragraph
mode by setting 'fillColumn' to a very large number and executing
'fillRegion' on the text.
=============================================================================
== Printing
=============================================================================
The current window is printed through the "Page Setup..." and "Print..."
File menu items. The variable 'suppressHeader' controls whether a header
is printed on each page, 'leftMargin', 'topMargin', and 'bottomMargin'
control margins on the printed page.
=============================================================================
== Tips and other Miscellaneous Diversions...
=============================================================================
• When a window is "dirty" (has unsaved changes), a
diamond appears in the title bar and next to the
corresponding item in the Windows menu.
• All dialogs that have editable text can use the Cut,
Copy, and Paste menu command equivalents.
• In all dialogs, non-editable controls can be selected
by typing Command-<first char of control>. If there
are no editable controls in the dialog, simply typing
the first letter of the desired control suffices.
• Dirty windows are marked with a diamond in the
window's title bar. The corresponding menu items in
the 'Window' menu will also have a diamond mark next
to it.
• Set the flag 'undoOn' to 0 in order to speed up long
replace-all and macro modifications.
• After a piece of text has been yank'd or paste'd, the
'mark' is set to the beginning of the new text and the
selection is at the end. 'markHilite' will now hilite
the entire insertion. This is especially useful when
moving code. Cut the code, insert at a new position,
select the inserted text by selecting "Edit:Hilite", and
then use "Edit:Shift Left" and "Edit: Shift Right" to move
the text to the proper indentation.
=============================================================================
== Variables
=============================================================================
There are two different kinds of variables in the Alpha world. These are
internal variables and Tcl variables. You can only directly access the
latter. However, the internal variables can be modified by creating a Tcl
variable of the same name and "binding" it to its internal counterpart via
the 'shadowVar' command (See the "Alpha Tcl Extensions" file under the
"Help" menu for 'shadowVar's syntax). The following is a listing of the
internal variables that can be bound using 'shadowVar':
autoSave • If TRUE, buffers (except untitled buffers) are automatically
saved every 'changesLim' changes.
backDir • Directory in which to store backup files.
backSuffix • Suffix to append to backup files.
backup • if TRUE, the default Tcl proc 'saveHook' makes a backup
of a file before the data is written. The default backup scheme has
extension "~".
blockCursor • if true, Alpha uses a block cursor instead of a vertical
line.
bwWindows • if true, Alpha will use 1-bit windows
even if color is available. This speeds
refresh quite a bit on slow color
machines such as the IIsi.
changesLim • number of changes to a window before
garbage collection or autosave is done.
currFileSet • name of currently selected file set.
defaultFont • font to use on new windows and files
which don't have associated font
specification resources.
defHeight • If 'fullScreen' set, this is default
height in pixels.
defWidth • If 'fullScreen' set, this is default
width in pixels.
elecLBrace • Electric 'C' left brace on.
elecRBrace • Electric 'C' right brace on.
electricSemi • Electric 'C' semicolon on.
fillColumn • Number of columns use as limit for
"fill" routines. See 'leftFillColumn'
fontSaving • if '-1', Alpha never saves font info,
if '1', Alpha always saves font info,
'0', Alpha saves font info if the font
or size is different than the default.
fontSize • Default size of fonts used to display
files.
fullNames • Windows display pathnames instead of
mere file names.
fullScreen • If on, all windows are start in the
same place, and have the dimension
specified by 'defHeight' and
'defWidth'.
funcPar • Used in defining the "Func" title-bar menu, see Alpha
help.
funcExpr • Set to the regular expression that
ALPHA uses to find function
declarations.
funcTitle • Text to put in title-bar menu header.
See the Popup-Menus section for more
information.
horScrollBar • If set, use horizontal scrollbar.
includePath • A list of the path-names of the
directories to search for include
files, separated by semi-colons, such
as:
"Disk:C:edit;Disk:C:THINK C:include;"
The current directory can be included
by using consecutive semi-colons as:
"Disk:C:edit;Disk:C:THINK C:inc;;"
indentOnCR • Auto-indent on carriage return.
leftFillColumn • Number of blanks left at beginning of
lines by 'fill' routines.
markLabel • If a window is opened through either 'edit' or 'fileMenu'
and the '-m' option was set, this string is used as the label of the
marks menu.
markSorting • Controls the order in which marks are saved into a file.
'0' means the order in which they are defined, '1' means file
order, and '2' means alphabetical order.
moveInsertion • if true, 'pageBack' and 'pageForward'
move the insertion point
numWinsToTile • specifies the number of windows tile
commands should affect.
openAllFIles • if true, or it option key down, files
of all types are openable, not just
'TEXT'.
optionIsMeta • If set, the key combination with escape
is used instead of the option key
combination. Note that some
combinations with option chars are
dead keys.
paraColumn • Alpha automatically wraps files
that contains lines longer than this.
posActivate • If true, then merely moving the mouse
over a window activates. For those
X11-twm lovers.
powerThumb • If true, vertical scrollbars have power thumbs.
protoFile • name of file to dump prototypes into.
replaceStr • Text for the search and replace functions.
savedState • set to either "mpw", "think", or "none" depending on how
much information you wish Alpha to save in the resource fork of the
files you edit. See the "Files" section of this file for more
information.
searchStr • Text for the search and replace functions.
showRowCol • if set, row and col are continuously
displayed in the title bar.
showMenuHeads • If set, the function and mark menus can
be selected from the title bar.
intelCutPaste • If enabled, cut and paste routines try to
intelligently treat surrounding white space.
sortColumn • column to use for sort routine.
sortedIsDefault• if set, sorted is the default for
function and section menus.
suppressHeader • Suppress header on printed pages.
tabSize • Default number of characters per tab.
tagFile • complete path-name of tag file
tempMem • if zero, Alpha will not use temporary
memory.
undoOn • used to turn undo on and off. When undo
is turned off, all undo info is lost.
Useful when doing global replaces, etc.
wordBreak • Regular expression used to defines words for all internal
operations.
wordBreakPreface • Prepended to 'wordBreak' when looking backwards for a
word. See the "Word Break" section of this file for more
information.
wordWrap • if true, lines exceeding 'fillColumn'
in length are automatically wrapped
during normal text insertion (typing)
================================================================================
== Spellchecking
================================================================================
Alpha has the capability to interact with the spell-check 'Excalibur',
written by Robert Gottshall and Rick Zaccone. The menu item 'Spellcheck
Window' is always available in either the menu w/ Excalibur's icon, or
under the Latex menu (with the OzTex menu). Selecting this item will start
up Excalibur and send an OpenDoc event describing the current window. For
version 1.4 and earlier, if Alpha has to launch Excalibur you will need to
dismiss Excalibur's opening dialog by hitting the Cancel button.
Subsequent selections of the menu item will switch right into Excalibur
with the correct file displayed. In future versions, this will become even
more automatic.
Excalibur is free, but not in the public domain. It can be obtained from
all the usual Internet ftp sites, as well as cs.rice.edu under
public/Alpha.
===========================================================================
== INTERNATIONAL USERS
===========================================================================
Remember, if you want to use anything other than the US KCHR resource
(si vous voulez ecrire en francais, par exemple), change the line:
init 0 2
of :Tcl:SystemCode:AlphaBits.tcl to
init1 2
and restart. Alpha will now use your native KCHR, but the key binding labels
(such as F1 etc.) may not work, and option-e etc. are now "dead keys".
===========================================================================
== Drag and Drop Editing
===========================================================================
Alpha supports drag and drop cut, copy, clear, and paste. To use this
feature, select some text, then move the cursor over the selected text.
The cursor should then turn into an open hand. Mouse down, and move the
cursor to the place you wish to paste the text. When the mouse is
released, the hilited text is moved to the new location.
Option-mouse does a "copy" instead. Dragging the cursor from the selected
text off the edge of the window will clear it.
Alpha does not currently support drag and drop editing between windows or
files.